package com.test.springboot.springboot3testdemo3.service;

import java.time.LocalDateTime;
import java.util.concurrent.ThreadPoolExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/9/13-13:05
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@Service
public class ThreadPoolTestService {
  private static final Logger LOGGER = LoggerFactory.getLogger(ThreadPoolTestService.class);

  @Autowired
  @Qualifier("threadPoolExecutor")
  private ThreadPoolExecutor executor;

  @Scheduled(fixedDelay = 60_000)
  public void testThreadPool() {
    executor.execute(() -> LOGGER.info("[thread-pool] execute a task at {}", LocalDateTime.now()));
  }
}
